home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
simula
/
books
/
books.lha
/
kirkerud
/
encrypt.sim
< prev
next >
Wrap
Text File
|
1993-08-16
|
987b
|
33 lines
! Example 3.8;
begin
character char_in_word;
integer char_number, ! This is a declaration of a variable;
crypt_add = 13; ! This is a declaration of a constant;
outtext( "Write a word to be encrypted > "); breakoutimage;
inimage;
char_in_word := inchar;
while letter(char_in_word) do
begin
char_number := rank(char_in_word) + crypt_add;
if char_in_word le 'Z'
! Then char_in_word is an upper case letter;
and char_number > rank('Z')
! and the encrypted letter is after 'Z';
then char_number := char_number - rank('Z') + rank('A') - 1
! the encrypted letter is put after 'A';
else if char_number > rank('z') then
char_number := char_number - rank('z') + rank('a') - 1;
! Correspondingly for lower case letters;
outchar(char(char_number));
char_in_word := inchar;
end;
outtext(" is the encrypted version!");
outimage;
end